﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
using System.Text;
using Coslen.TahorCRM.Domain.Model.Entities;
using Coslen.TahorCRM.Domain.Repositories.Concretes;
using Coslen.TahorCRM.Domain.Repositories.Interfaces;
using Ninject;

namespace Coslen.TahorCRM.Security
{
    public class TahorMembershipService
    {
        [Inject]
        public IUserRepository UserRepository;

        public TahorMembershipService()
            : this(new UserRepository())
        {
        }

        public TahorMembershipService(UserRepository userRepository)
        {
            UserRepository = userRepository;
        }

        public IPrincipal GetPrincipalForUserName(string userName, bool isAuthenticated)
        {
            User user = UserRepository.GetUserByUserName(userName);
            TahorPrincipal tahorPrincipal = new TahorPrincipal(user, isAuthenticated);

            return tahorPrincipal;
        }
    }
}
